﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class LinhVuc_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_LinhVuc");
       }
       public int Insert(LinhVuc_Public maLinhVuc, LinhVuc_Public tenLinhVuc, LinhVuc_Public ghiChu)
       {
           int Npara = 3;
           string[]name=new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaLinhVuc";
           value[0] = maLinhVuc.MaLinhVuc;
           name[1] = "@TenLinhVuc";
           value[1] = tenLinhVuc.TenLinhVuc;
           name[2] = "@GhiChu";
           value[2] = ghiChu.GhiChu;

           return kn.update("Insert_LinhVuc",name,value,Npara);


       }
       public int Update(LinhVuc_Public maLinhVuc, LinhVuc_Public tenLinhVuc, LinhVuc_Public ghiChu)
       {
           int Npara = 3;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaLinhVuc";
           value[0] = maLinhVuc.MaLinhVuc;
           name[1] = "@TenLinhVuc";
           value[1] = tenLinhVuc.TenLinhVuc;
           name[2] = "@GhiChu";
           value[2] = ghiChu.GhiChu;

           return kn.update("Update_LinhVuc", name, value, Npara);


       }
       public int Delete(LinhVuc_Public maLinhVuc)
       {
           int Npara = 1;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@MaLinhVuc";
           value[0] = maLinhVuc.MaLinhVuc;

           return kn.update("Delete_LinhVuc", name, value, Npara);


       }
    }
}
